import os
import sys
import uvicorn
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from pathlib import Path
from Request import (
    IPO_request,  # IPO 审核
    inquiry
)

ROOT_DIR = Path(__file__).resolve().parent
sys.path.append(str(ROOT_DIR))  # 添加项目根目录到模块搜索路径
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))


app = FastAPI(
    title="ipo-inquiry",
    description="基于大模型搭建的上市申请书智能问询服务",
    version="0.0.1",
)

app.include_router(IPO_request.router)  # IPO 审核
app.include_router(inquiry.router, prefix="/api/inquiry", tags=["根据上市申请书问询"])


app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
    expose_headers=["Content-Disposition"]
)

if __name__ == '__main__':
    # uvicorn.run('api_starter:app', host='192.168.31.93', port=8002, reload=True)
    # uvicorn.run('api_starter:app', host='192.168.31.64', port=8008, reload=False)
    # uvicorn.run('api_starter:app', host='192.168.31.93', port=8003, reload=False)
    # uvicorn.run('api_starter:app', host='127.0.0.1', port=8003, reload=False)

    uvicorn.run("api_starter:app", host="0.0.0.0", port=8001, reload=False)
